cmake_minimum_required(VERSION 3.5)
add_compile_options(-std=c++20)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(co_async)

set(JSON_URL "https://github.com/nlohmann/json/raw/develop/single_include/nlohmann/json.hpp")
set(JSON_LOCAL_PATH "${CMAKE_SOURCE_DIR}/json.hpp")

# 检查文件是否存在
if(NOT EXISTS ${JSON_LOCAL_PATH})
    message(STATUS "json.hpp not found. Downloading from ${JSON_URL}...")
    file(DOWNLOAD ${JSON_URL} ${JSON_LOCAL_PATH})
else()
    message(STATUS "json.hpp already exists at ${JSON_LOCAL_PATH}.")
endif()

add_library(co_server http.cc websocket.cc)

target_link_libraries(co_server uring crypto z)

add_subdirectory(test)